<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>院校排名</title>
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/bootstrap/css/bootstrap-submenu.css">
<!--    <link rel="stylesheet" href="css/bootstrap.min.css">-->
<!--    <link rel="stylesheet" href="css/bootstrap-submenu.css" />-->

</head>
<!--<%!int regionNowPage;//当前页数-->
<!--int page1;//总共页数-->
<!--int i = 1;-->
<!--int cityNowPage;//全国当前页数-->
<!--int citySumPage;//全国总页数-->
<!--%>-->

<!--<%-->
<!--try{-->
<!--if (!session.getAttribute("province").equals("全国")) {-->
<!--regionNowPage = Integer.parseInt(session.getAttribute("regionNowPage").toString());-->
<!--page1 = Integer.parseInt(session.getAttribute("universityRankTotalPage").toString());-->

<!--System.out.println("非全国的页面信息");-->
<!--System.out.println(regionNowPage);-->
<!--System.out.println(page1);-->
<!--}-->
<!--else{-->
<!--cityNowPage = Integer.parseInt(session.getAttribute("cityNowPage").toString());-->
<!--citySumPage = Integer.parseInt(session.getAttribute("citySumPage").toString());-->

<!--System.out.println(cityNowPage);-->
<!--System.out.println(citySumPage);-->
<!--}-->
<!--}-->
<!--catch(Exception e){-->
<!--e.printStackTrace();-->
<!--}-->
<!--%>-->

<body>
<!--导航栏-->
<div class="container" id="frontTop"></div>

<div class="container marginLi">
    <div class="container text-center">
        <h1>2019全国各高校排名</h1>
    </div>
    <h3>院校所在地</h3>
    <ul id="myTab" class="list-inline row" style="padding-top: 10px">
        <li class="col-md-1" style="padding-bottom: 10px">
            <a href="universityRank?pageNum=1&province=全国" > 全国 </a></li>
        <c:forEach items="${listAllPrivinces}" var="privince">
            <li class="col-md-1"><a href="universityRank?pageNum=1&province=${privince.provinceName}">${privince.provinceName}</a>
            </li>
        </c:forEach>

    </ul>
</div>

<div class="container">
    <table class="table table-hover">
        <thead class="thead-dark">
        <tr>
            <th>院校名次</th>
            <th>院校名称</th>
            <th>院校所在地</th>
            <th>院校类型</th>
            <th>院校属性</th>
        </tr>
        </thead>
        <tbody>

<!--        <%-->
<!--        if (session.getAttribute("province").equals("全国")) {-->
<!--        System.out.println("全国");-->
<!--        %>-->
        <c:forEach items="${allUniversities}" var="university1">
            <tr>
                <td><%=i++%></td>
                <td>${university1.schoolName}</td>
                <td></td>
                <td></td>
                <td>${university1.schoolAttribute}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<!--  全国的分页-->
<div class="container">
    <ul class="pagination offset-md-3" >
        <c:if test="${allUniversitiesPage.hasPrev}">
            <li><a class="btn btn-primary "
                     href="${allUniversitiesPage.url}?pageNum=1&province=全国">首页</a></li>
            <li><a class="btn  btn-primary"
                   href="${allUniversitiesPage.url}?pageNum=${allUniversitiesPage.pageNo- 1}&province=全国">上一页</a></li>
        </c:if>


        <c:forEach var="i" begin="1" end="${allUniversitiesPage.totalPageNo}"
                   step="1">
            <li><a class="btn btn-primary page${i}"
                   href="${allUniversitiesPage.url}?pageNum=${i}&province=全国">${i}</a></li>
        </c:forEach>
        <c:if test="${allUniversitiesPage.hasNext}">
            <li><a class="btn btn-primary "
                   href="${allUniversitiesPage.url}?pageNum=${allUniversitiesPage.pageNo+ 1}&province=全国">下一页</a></li>
            <li><a class="btn btn-primary "
                   href="${allUniversitiesPage.url}?pageNum=${allUniversitiesPage.totalPageNo}&province=全国">末尾</a></li>
        </c:if>
    </ul>
</div>


<c:forEach items="${listUniversities}" var="university">
    <tr>
        <td><%=i++%></td>
        <td>${university.schoolName}</td>
        <td>${university.city} </td>
        <td></td>
        <td>${university.schoolAttribute}</td>
    </tr>
</c:forEach>

</tbody>
</table>
</div>
<ul class="pagination">
    <li style="margin-left: 250px"><a
            class="btn btn-primary firstPage"
            href="universityRank?pageNum=1&province=${province}">首页</a></li>
    <li><a class="prePage btn  btn-primary"
           href="universityRank?pageNum=${regionNowPage-1}&province=${province}">上一页</a></li>

    <c:forEach var="i" begin="1" end="${universityRankTotalPage}"
               step="1">
        <li><a class="btn btn-primary pageNum${i}"
               href="universityRank?pageNum=${i}&province=${province}">${i}</a></li>
    </c:forEach>

    <li><a class="btn btn-primary nextPage"
           href="universityRank?pageNum=${regionNowPage+1}&province=${province}">下一页</a></li>
    <li><a class="btn btn-primary lastPage"
           href="universityRank?pageNum=${regionSumPage1}&province=${province}">末尾</a></li>
</ul>
</div>


<script src="js/jquery-3.2.1.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-3.3.0.js"></script>
<script type="text/javascript" src="js/sweetalert.min.js"></script>
<!-- bootstrap引用 -->
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<!--底部信息  -->
<div class="container" id="frontBottom"></div>
<script type="text/javascript">
    $(document).ready(function() {

        for (var i = 1; i <=<%=page1%>	; i++) {
            if (i ==<%=regionNowPage%>	)
                $(".pageNum" + i + "").addClass("disabled");
            else {
                $(".pageNum" + i + "").removeClass("disabled");
            }
        }
    <%if (regionNowPage == page1) {%>
            $(".nextPage").addClass("disabled");
            $(".lastPage").addClass("disabled");
        <%} else {%>
            $(".nextPage").removeClass("disabled");
            $(".lastPage").removeClass("disabled");
        <%}%>

    <%if (regionNowPage == 1) {%>
            $(".firstPage").addClass("disabled");
            $(".prePage").addClass("disabled");
        <%} else {%>
            $(".firstPage").removeClass("disabled");
            $(".prePage").removeClass("disabled");
        <%}%>

        //判断全国的当前页面

        for(var i=0;i<<%=citySumPage%>;i++){
            if(i == <%=cityNowPage%>){
                $(".page"+i+"").addClass("disabled");
            }
            else{
                $(".page"+i+"").removeClass("disabled");
            }
        }
    });
</script>


</body>
</html>